package entity

import "time"

type OrderPayment struct {
	ID         int       `gorm:"column:id;PRIMARY_KEY"`
	OrderNo    string    `gorm:"column:order_no"`
	PaymentNo  string    `gorm:"column:payment_no"`
	Amount     float64   `gorm:"column:amount"`
	TradeState string    `gorm:"column:trade_state"`
	Attr       string    `gorm:"column:attr"`
	PayTime    time.Time `gorm:"column:pay_time"`
	CreatedAt  time.Time `gorm:"column:created_at"`
}

func (OrderPayment) TableName() string {
	return "l_order_payment"
}

func NewOrderPayment(order *Order, transId string, statFlag string) *OrderPayment {
	return &OrderPayment{
		OrderNo:    order.Number,
		PaymentNo:  transId,
		TradeState: statFlag,
		Amount:     order.Amount,
		PayTime:    time.Now(),
	}
}
